summaryrefslogtreecommitdiff
path: root/app/[lng]/auth/reset-password/page.tsx
blob: 1900f7b93237f2e3174b350c81e30b4b3d882d1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// app/[lng]/auth/reset-password/page.tsx

import { redirect } from 'next/navigation';
import { validateResetTokenAction } from '@/lib/users/auth/partners-auth';
import InvalidTokenPage from '@/components/login/InvalidTokenPage';
import ResetPasswordForm from '@/components/login/reset-password';
import { getPasswordPolicy } from '@/lib/users/auth/passwordUtil';

interface Props {
  searchParams: Promise<{ token?: string }>;
}

export default async function ResetPasswordPage(props: Props) {
  const searchParams = await props.searchParams;
  const token = searchParams.token;

  // 토큰이 없는 경우 로그인 페이지로 리다이렉트
  if (!token) {
    redirect('/partners');
  }

  // 서버에서 토큰 검증
  const tokenValidation = await validateResetTokenAction(token);
  
  // 토큰이 유효하지 않은 경우
  if (!tokenValidation.valid) {
    return (
      <InvalidTokenPage
        expired={tokenValidation.expired || false}
        error={tokenValidation.error}
      />
    );
  }

  // 패스워드 정책 로드
  const passwordPolicy = await getPasswordPolicy();

  // 유효한 토큰인 경우 폼 표시
  return (
    <div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
      <ResetPasswordForm
        token={token}
        userId={tokenValidation.userId!}
        passwordPolicy={passwordPolicy}
      />
    </div>
  );
}